<%@ page import="java.net.URLDecoder" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>欢迎登录校园宿舍管理系统</title>
    <!--可以在收藏夹中显示出图标-->
    <link rel="Bookmark" type="image/png" href="/images/badge.png"/>
    <!--可以在地址栏中显示出图标-->
    <link rel="icon" type="image/png" href="/images/badge.png"/>
    <link rel="shortcut icon" type="image/png" href="/images/badge.png"/>
    <link href="/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css"/>
    <link href="/layui/css/layui.css" rel="stylesheet" type="text/css"/>
    <link href="/css/style.css" rel="stylesheet" type="text/css"/>

    <script src="/js/jquery.js" type="text/javascript"></script>
    <script src="/js/cloud.js" type="text/javascript"></script>
    <script src="/bootstrap/js/bootstrap.js" type="text/javascript"></script>
    <script src="/layui/layui.js" type="text/javascript"></script>
    <script src="/js/custom/login.js" type="text/javascript"></script>

    <script>
        $(function () {
            $('.loginbox').css({'position': 'absolute', 'left': ($(window).width() - 692) / 2});
            $(window).resize(function () {
                $('.loginbox').css({'position': 'absolute', 'left': ($(window).width() - 692) / 2});
            })
        });
    </script>
</head>

<body style="background-color:#1c77ac; background-image:url(/images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">

<div id="mainBody">
    <div id="cloud1" class="cloud"></div>
    <div id="cloud2" class="cloud"></div>
</div>

<div class="logintop">
    <span>欢迎登录后台管理界面平台</span>
    <ul>
        <li><a href="#" data-toggle="modal" data-target="#help">帮助</a></li>
        <li><a href="#" data-toggle="modal" data-target="#about">关于</a></li>
    </ul>
</div>
<form action="/UserController.do?action=login" method="post">
    <div class="loginbody">
        <span class="systemlogo"></span>
        <%
            String username="";
            String password="";
            Boolean ischecked=false;
            String role="";
            Cookie[] cookies= request.getCookies();
            if(cookies!=null){
                for(int i=0;i<cookies.length;i++){
                    Cookie c=cookies[i];
                    if(c.getName().equals("userToken")){
                        String value = URLDecoder.decode(c.getValue(),"UTF-8");
                        String[] userNameAndPass=value.split(" ");
                        username=userNameAndPass[0];
                        password=userNameAndPass[1];
                        ischecked=true;
                    }
                    if(c.getName().equals("role_cookie")){
                        role=URLDecoder.decode(c.getValue(),"UTF-8");
                    }
                }
            }
        %>
        <div class="loginbox">
            <ul>
                <li><input name="username" type="text" id="loginuser" value="<%=username%>" class="loginuser"
                           onclick="JavaScript:this.value=''"/></li>
                <li><input name="password" type="password" id="loginpwd" value="<%=password%>" class="loginpwd"
                           onclick="JavaScript:this.value=''"/></li>
                <li>
                    <input type="submit" class="loginbtn" value="登录"/>
                    <label style="width: 120px">
                        <select name="role" class="form-control" id="role">
                            <option value="1" <%=role.equals("1")?"selected":""%>>超管</option>
                            <option value="2" <%=role.equals("2")?"selected":""%>>宿管</option>
                            <option value="3" <%=role.equals("3")?"selected":""%>>学生</option>
                        </select>
                    </label>
                    <label><input name="isRememberPwd" type="checkbox" value="1" id="isRememberPwd" <%=ischecked==true?"checked":""%>/>记住密码</label>
                    <span style="color: red">${msg}</span>
                </li>
            </ul>
        </div>
    </div>
</form>

<div class="loginbm">版权所有 2021 <a href="http://www.aspku.com">aspku.com</a> 仅供学习交流，勿用于任何商业用途</div>

<!-- 帮助 -->
<div class="modal fade" id="help" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">帮助</h4>
            </div>
            <div class="modal-body">
                <p>本系统是基于SpringBoot开发的学生宿舍管理系统！</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!-- 关于 -->
<div class="modal fade" id="about" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">关于</h4>
            </div>
            <div class="modal-body">
                <p>本系统是基于SpringBoot开发的学生宿舍管理系统！</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!-- 忘记密码 -->
<div class="modal fade" id="forgotPassword" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">忘记密码</h4>
            </div>
            <div class="modal-body">
                <p>请联系管理员进行重置密码...</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
